import request from '../../utils/request'

// 测试token
export function tokenTest() {
    return request({
        url: '/test/token',
        method: 'get'
    })
}

// 管理员登陆
export function login(data) {
    return request({
        url: '/admin/login',
        method: 'post',
        data
    })
}


// 用户退出
export function logout() {
    return request({
        url: '/admin/logout',
        method: 'post'
    })
}

// 获取首页活动数据
export function homeActivityService() {
    return request({
        url: '/admin/home/activity',
        method: 'get'
    })
}

// 获取首页资讯数据
export function homeInfoService() {
    return request({
        url: '/admin/home/info',
        method: 'get'
    })
}


/**
 * 用户信息管理
 */

// 分页查询用户
export function pageQueryUser(params) {
    return request({
        url: '/admin/pageQuery',
        method: 'get',
        params
    })
}
// 添加用户
export function addUserReq(data) {
    return request({
        url: '/admin',
        method: 'post',
        data,
    })
}
// 根据id查询用户信息
export function queryUserById(id) {
    return request({
        url: `/admin/${id}`,
        method: 'get',
    })
}
// 修改用户信息
export function updateUserReq(data) {
    return request({
        url: '/admin',
        method: 'put',
        data
    })
}
// 逻辑删除
export function logicDeleteUserById(id) {
    return request({
        url: `/admin/logicDel/${id}`,
        method: 'delete'
    })
}
// 批量逻辑删除
export function logicBatchDeleteUserByIds(ids) {
    return request({
        url: `/admin/logicBatchDel`,
        method: 'delete',
        data: ids,
    })
}
// 获取角色信息
export function queryRole() {
    return request({
        url: '/admin/getRole',
        method: 'get'
    })
}

/**
 * 分页查询老人信息
 */
export function pageQueryOld(params) {
    return request({
        url: '/admin/oldster',
        method: 'get',
        params,
    })
}
export function addOldReq(data) {
    return request({
        url: '/admin/oldster',
        method: 'post',
        data,
    })
}
// 通过id查询老人信息
export function queryOldById(id) {
    return request({
        url: `/admin/oldster/${id}`,
        method: 'get'
    })
}
// 修改老人信息
export function updateOldReq(data) {
    return request({
        url: '/admin/oldster',
        method: 'put',
        data
    })
}
// 逻辑删除
export function logicDeleteOldById(id) {
    return request({
        url: `/admin/oldster/logicDel/${id}`,
        method: 'delete'
    })
}
// 批量逻辑删除
export function logicBatchDeleteOldByIds(ids) {
    return request({
        url: `/admin/oldster/logicBatchDel`,
        method: 'delete',
        data: ids,
    })
}
export function getOldsterStatus() {
    return request({
        url: '/admin/oldster/getOldsterStatus',
        method: 'get'
    })
}

/**
 * 资讯查询
 * @param data 
 * @returns 
 */
export function pageQueryInfo(data) {
    return request({
        url: '/admin/info',
        method: 'get',
        params: data
    })
}


export function updateInfo(data) {
    return request({
        url: '/admin/info',
        method: 'post',
        data
    })
}


/**
 * 修改资讯状态
 * @param data 
 * @returns 
 */
export function updateInfoStatus(data) {
    return request({
        url: '/admin/info/changeStatus',
        method: 'post',
        data
    })
}

export function getInfoById(id) {
    return request({
        url: `/admin/info/${id}`,
        method: 'get',
    })
}

/**
 * 获取资讯类型
 * @returns 
 */
export function getInfoType(params) {
    return request({
        url: '/admin/info/type',
        method: 'get',
        params,
    })
}
// 逻辑删除
export function logicDeleteInfoById(id) {
    return request({
        url: `/admin/info/logicDel/${id}`,
        method: 'delete'
    })
}
// 批量逻辑删除
export function logicBatchDeleteInfoByIds(ids) {
    return request({
        url: `/admin/info/logicBatchDel`,
        method: 'delete',
        data: ids,
    })
}

// 爬取资讯信息
export function addInfo(params) {
    return request({
        url: `/admin/info/jsonpInfo/${params}`,
        method: 'get',
    })
}


/**
 * 分页查询活动信息
 */
export function pageQueryActivity(params) {
    return request({
        url: '/admin/activity',
        method: 'get',
        params,
    })
}
/**
 * 添加活动
 */
export function addActivityReq(data) {
    return request({
        url: '/admin/activity',
        method: 'post',
        data,
    })
}
/**
 * 修改活动状态
 */
export function updateActivityReq(data) {
    // console.log('--->',data);

    return request({
        url: '/admin/activity',
        method: 'put',
        data
    })
}
// 通过id查询活动信息
export function queryActivityById(id) {
    return request({
        url: `/admin/activity/${id}`,
        method: 'get',
    })
}
/**
 * 查询活动类型
 */
export function queryActivityType(params) {
    return request({
        url: '/admin/activity/type',
        method: 'get',
        params,
    })
}
// 逻辑删除
export function logicDeleteActivityById(id) {
    return request({
        url: `/admin/activity/logicDel/${id}`,
        method: 'delete'
    })
}
// 批量逻辑删除
export function logicBatchDeleteActivityByIds(ids) {
    return request({
        url: `/admin/activity/logicBatchDel`,
        method: 'delete',
        data: ids,
    })
}


/**
 * 分页查询活动报名信息
 */
export function pageQueryActivityReg(params) {
    return request({
        url: '/admin/activityReg',
        method: 'get',
        params,
    })
}
// 修改活动报名的状态
export function updateActivityRegReq(data) {
    return request({
        url: '/admin/activityReg',
        method: 'put',
        data,
    })
}
// 逻辑删除
export function logicDeleteActivityRegById(id) {
    return request({
        url: `/admin/activityReg/logicDel/${id}`,
        method: 'delete'
    })
}
// 批量逻辑删除
export function logicBatchDeleteActivityRegByIds(ids) {
    return request({
        url: `/admin/activityReg/logicBatchDel`,
        method: 'delete',
        data: ids,
    })
}


/**
 * 志愿者相关
 */
export function pageQueryVolunteer(data) {
    return request({
        url: '/admin/volunteer',
        method: 'get',
        params: data
    })
}
export function logicDeleteVolunteerById(id) {
    return request({
        url: `/admin/volunteer/logicDel/${id}`,
        method: 'delete'
    })
}
export function logicBatchDeleteVolunteerByIds(ids) {
    return request({
        url: `/admin/volunteer/logicBatchDel`,
        method: 'delete',
        data: ids
    })
}
// 修改志愿者信息
export function updateVolunteer(data) {
    return request({
        url: '/admin/volunteer',
        method: 'put',
        data
    })
}

/**
 * 分页查询建议信息
 */
export function pageQueryFeedback(params) {
    return request({
        url: '/admin/feedback',
        method: 'get',
        params,
    })
}
// 软删除建议信息
export function updateDeleteFeedback(data) {
    return request({
        url: '/admin/feedback',
        method: 'put',
        data
    })
}
// 逻辑删除
export function logicDeleteFeedbackById(id) {
    return request({
        url: `/admin/feedback/logicDel/${id}`,
        method: 'delete'
    })
}
// 批量逻辑删除
export function logicBatchDeleteFeedbackByIds(ids) {
    return request({
        url: `/admin/feedback/logicBatchDel`,
        method: 'delete',
        data: ids,
    })
}

// 添加活动类别
export function addActivityCategoryService(data) {
    return request({
        url: '/admin/activityCategory/add',
        method: 'post',
        data
    })
}

// 修改活动类别
export function updateActivityCategoryService(data) {
    return request({
        url: '/admin/activityCategory/update',
        method: 'put',
        data
    })
}

// 删除活动类别
export function delActivityCategoryService(id) {
    return request({
        url: `/admin/activityCategory/${id}`,
        method: 'delete',
    })
}

// 添加活动类别
export function addInfoCategoryService(data) {
    return request({
        url: '/admin/infoCategory/add',
        method: 'post',
        data
    })
}

// 修改资讯类别
export function updateInfoCategoryService(data) {
    return request({
        url: '/admin/infoCategory/update',
        method: 'put',
        data
    })
}

// 删除资讯类别
export function delInfoCategoryService(id) {
    return request({
        url: `/admin/infoCategory/${id}`,
        method: 'delete',
    })
}